package cn.codecrab.ai.langchain4j.controller;

import cn.codecrab.ai.langchain4j.assistant.XiaoZhiAgent;
import cn.codecrab.ai.langchain4j.entity.from.ChatForm;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * @author 王刚
 * @since 2025年05月10日 17:07
 */
@Tag(name = "硅谷小智")
@RestController
@RequestMapping("/xiao-zhi")
public class XiaoZhiController {

    @Resource
    private XiaoZhiAgent xiaoZhiAgent;

    @Operation(summary = "对话")
    @PostMapping(value = "/chat", produces = "text/stream;charset=utf-8")
    public Flux<String> chat(@RequestBody ChatForm chatForm) {
        return xiaoZhiAgent.chat(chatForm.getMemoryId(), chatForm.getMessage());
    }

}
